package top.lshaci.learning.springboot.rabbitmq.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * TestListener
 *
 * <pre>
 *     必须 @EnableRabbit 才能使用 @RabbitListener
 * </pre>
 *
 * @author lshaci
 * @since 1.0.0
 */
@Component
public class TestListener {

    @RabbitListener(queues = "test")
    public void springboot(Message rawMessage, String message, Channel channel) throws IOException {
        System.err.println(message);
        System.err.println(rawMessage);
        System.err.println(channel);
        channel.basicAck(rawMessage.getMessageProperties().getDeliveryTag(), false);
    }

}
